package com.client.clovece;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.Random;

import javax.swing.ImageIcon;


public class Dice {
	private ArrayList <ImageIcon> a;
	private int curval, lastval;
	Random generator;
	Calendar cal;
	/** argument parent se muze odstranit */
	public Dice(LocalGame parent){
		cal = new GregorianCalendar(); 
		a = new ArrayList<ImageIcon>();
		generator = new Random(cal.get(Calendar.MILLISECOND));
		initIcons();
	}
	
	private void initIcons(){
		Configuration c = Configuration.getInstance();
		String paths[] = c.getPaths();
		a.add(new ImageIcon(paths[ButtonStates.DICE1.ordinal()]));
		a.add(new ImageIcon(paths[ButtonStates.DICE2.ordinal()]));
		a.add(new ImageIcon(paths[ButtonStates.DICE3.ordinal()]));
		a.add(new ImageIcon(paths[ButtonStates.DICE4.ordinal()]));
		a.add(new ImageIcon(paths[ButtonStates.DICE5.ordinal()]));
		a.add(new ImageIcon(paths[ButtonStates.DICE6.ordinal()]));
		a.add(new ImageIcon(paths[ButtonStates.DICEEMPTY.ordinal()]));
	}
	
	public void thrw(){
		lastval = curval;
		curval = generator.nextInt(6);
	}
	
	public int getVal(){
		return curval+1;
	}
	
	public int getLastVal(){
		return lastval+1;
	}
	
	public ImageIcon getIcon(){
		return a.get(curval);
	}
}
